﻿<%@ Page Title="" Language="C#" MasterPageFile="~/U_masterP.master" AutoEventWireup="true"
    CodeFile="orders.aspx.cs" Inherits="orders" %>
<%@ Register Src="uc_main/menu_canhan.ascx" TagName="menu_canhan" TagPrefix="uc1" %>
<%@ Import Namespace="System.Linq" %>
<%@ Register Src="uc_main/sideBar_right.ascx" TagName="sideBar_right" TagPrefix="uc1" %>
<%@ Register Assembly="CollectionPager" Namespace="SiteUtils" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>Order</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="personalCss.css" rel="stylesheet" type="text/css" />
    <asp:HiddenField runat="server" ID="hdID" />
    <div id="content_top">
        <%--<div class="ngayCM"><p class="ngaycm2"><%# Eval("ngayTao","{0:dd/MM/yyyy}") %></p></div>--%>
        <div id="kep">
            <a href="#">Liên lạc với người bán</a></div>
        <div id="tags">
            <p class="title_p">
            </p>
        </div>
    </div>
    <div class="clear">
    </div>
    <div id="sub_content">
        <div id="content_left2" style="width: 100%;margin-left:0px;min-height:800px">
         <uc1:menu_canhan ID="menu_canhan2" runat="server" />
            <!-- noi dung chinh -->
            <!-- Conversation Topic -->
            <div class="orderInfo">
                <div class="first">
                    <div class="hinhgig">
                        <img id="hinhG" runat="server">
                    </div>
                    <div class="ghichu">
                        <h3 class="flag">
                            <span class="stt_wait" id="ttOrder" runat="server">Order dad </span>
                        </h3>
                        <h2>
                            <b><a href="#">
                                <asp:Label ID="UserName" runat="server"></asp:Label></a></b> sẽ <a id="ldetails"
                                    runat="server">
                                    <asp:Label ID="lblTenC" runat="server"></asp:Label></a> for $5</h2>
                    </div>
                </div>
                <div class="tiens">
                    <span>$5</span></div>
                <div class="clear">
                </div>
                <h3 class="ngaydat">
                    <div>
                        Đã đặt hàng của <b><a>
                            <asp:Label ID="lblNguoiBan2" runat="server"></asp:Label></a> vào
                            <asp:Label ID="lblDatedat" runat="server"></asp:Label></b></div>
                    <h3>
                    </h3>
                    <h3>
                    </h3>
                </h3>
            </div>
            <!-- Start Watrning -->
            <div class="controls" style="height: 40px">
                <div class="c" style="float: left; width: 41px">
                    <img src="img/success.png" />
                </div>
                <div style="float: left; vertical-align: middle">
                    <p style="vertical-align: middle; line-height: 40px; color: #5f5e5e; font-size: 14px">
                        Bạn đã thanh toán đơn hàng thành công. Người thực hiện công việc sẽ nhận được tiền
                        sau khi hoàn thành.</p>
                </div>
            </div>
            <!-- Start Consersation -->
            <div class="conversation">
                <asp:Repeater runat="server" ID="rpt">
                    <ItemTemplate>
                        <!-- Noi dung  chat-->
                        <div class="message">
                            <div class="wrap_mess">
                                <div class="mes_left">
                                    <div class="mes_left_1">
                                        <a>
                                            <img src='<%#Eval("idAccStr").ToString().Equals("none")?"avatar/avatarsystem":"avatar/ava"+Eval("idAccStr")%>.jpg'
                                                title='<%# Eval("VLGAccount.UsernameE") %>' width="31px" height="31px" /></a>
                                    </div>
                                    <div class="left_<%#Eval("typeCss") %>">
                                    </div>
                                </div>
                                <div style="width:830px" class="right_<%#Eval("typeCss") %>">
                                    <div class="noidung_mess ">
                                        <div class="noidung_mess_con">
                                            <p>
                                                <%# Eval("content") %></p>
                                            <span class="dangboi"><a href='documents/<%# Eval("fileNameSystem") %>' title="Nhấn để download file">
                                                <%# Eval("fileURL")%></a></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- END -->
                    </ItemTemplate>
                </asp:Repeater>
                <asp:Literal runat="server" ID="ltrSystemMessage"></asp:Literal>
                <div class="clear"></div>
                <!-- Nhap noi dung mess -->
                <div class="type_mes">
                    <asp:Panel runat="server" ID="pnMessage">
                        <div class="message2">
                            <div class="wrap_mess">
                                <div class="mes_left">
                                    <div class="mes_left_1">
                                        <a>
                                            <img id="currA" runat="server" /></a>
                                    </div>
                                    <div class="mes_left_2">
                                    </div>
                                </div>
                                <div style="width:830px" class="mess_right">
                                    <div class="noidung_mess">
                                        <label id="showMessage" style="text-align: left; cursor: pointer;">
                                            Gửi 1 tin nhắn đến <span id="ten">
                                                <asp:Label ID="lblNguoiNhan" runat="server"></asp:Label></span></label>
                                        <%-- <asp:Label runat="server" ID="showAction">--%>
                                        <label id="showAction" runat="server" style="text-align: right; float: right; cursor: pointer;">
                                            Thao tác khác <span id="Span1">
                                                <asp:Label ID="Label1" runat="server"></asp:Label></span></label>
                                        <hr />
                                        <div class="noidung_mess_con messageHide">
                                            <asp:TextBox ID="txt_mess" runat="server" CssClass="txt_mes" MaxLength="300" Rows="3"
                                                TextMode="MultiLine" Width="99%"></asp:TextBox>
                                            <div style="margin: 5px">
                                                <span class="attach"><a>Attach a file</a></span>
                                                <div class="send_">
                                                    <asp:Button ID="btn_SendMess" runat="server" CssClass="button_V" OnClick="btn_SendMess_Click"
                                                        OnClientClick="return check()" Text="Gửi" />
                                                </div>
                                                <asp:Literal ID="Literal1" runat="server"></asp:Literal>
                                                <div class="upfile">
                                                    <asp:FileUpload ID="FileUpload1" runat="server" />
                                                </div>
                                            </div>
                                        </div>
                                        <asp:Panel CssClass="pnSellerActive" runat="server" ID="pnSellerActive" Visible="false">
                                            <p>
                                                <input type="radio" runat="server" id="rdSLAT_1" checked="true" name="rdSellerActive" />
                                                <label>
                                                    Nhận đơn hàng</label>
                                                <input type="radio" runat="server" id="rdSLAT_0" name="rdSellerActive" />
                                                <label>
                                                    Hủy</label>
                                                <input type="radio" runat="server" id="rdSLAT_2" name="rdSellerActive" />
                                                <label>
                                                    Gửi yêu cầu cung cấp thêm thông tin</label></p>
                                            <p class="action-message" style="display: none; margin: 0">
                                                Vui lòng nhập lý do hủy hoặc yêu cầu khách hàng cung cấp thêm thông tin về đơn hàng
                                                <asp:TextBox runat="server" TextMode="MultiLine" ID="txtSellerRequiredMessage" CssClass="txt_mes"
                                                    MaxLength="300" Rows="3" Width="99%"></asp:TextBox></p>
                                            <asp:Button runat="server" CssClass="button_V" Text="Submit" ID="btnSellerRequireMessage"
                                                OnClick="btnSellerRequireMessage_Click" />
                                        </asp:Panel>
                                        <asp:Panel CssClass="pnSellerActive" runat="server" ID="pnSellerConfirm" Visible="false">
                                            <p>
                                                <input type="radio" name="pnSLCF" id="rdSLCF_1" checked="true" runat="server" />
                                                <label>
                                                    Hoàn thành</label>
                                                <input type="radio" name="pnSLCF" id="rdSLCF_0" runat="server" />
                                                <label>
                                                    Hủy</label>
                                            </p>
                                            <p class="action-message" style="display: none">
                                                Vui lòng nhập lý do hủy đơn hàng
                                                <asp:TextBox runat="server" TextMode="MultiLine" ID="txtSellerConfirm" CssClass="txt_mes"
                                                    MaxLength="300" Rows="3" Width="99%"></asp:TextBox></p>
                                            <asp:Button runat="server" CssClass="button_V" ID="btnSellerConfirm" Text="Submit"
                                                OnClick="btnSellerConfirm_Click" />
                                        </asp:Panel>
                                        <asp:Panel CssClass="pnSellerActive" runat="server" ID="pnSellerReject" Visible="false">
                                            <p>
                                                <input type="radio" name="pnSLRJ" id="rdSLRJ_2" runat="server" />
                                                <label>
                                                    Từ chối nhận đơn hàng</label>
                                                <input type="radio" name="pnSLRJ" id="rdSLRJ_1" checked="true" runat="server" />
                                                <label>
                                                    Hoàn thành</label>
                                                <input type="radio" name="pnSLRJ" id="rdSLRJ_0" runat="server" />
                                                <label>
                                                    Hủy</label>
                                            </p>
                                            <p class="action-message" style="display: none">
                                                Vui lòng nhập lý do hủy đơn hàng
                                                <asp:TextBox runat="server" TextMode="MultiLine" ID="txtSellerReject" CssClass="txt_mes"
                                                    MaxLength="300" Rows="3" Width="99%"></asp:TextBox></p>
                                            <asp:Button runat="server" CssClass="button_V" ID="btnSellerReject" Text="Submit"
                                                OnClick="btnSellerReject_Click" />
                                        </asp:Panel>
                                        <asp:Panel CssClass="pnSellerActive" runat="server" ID="pnBuyerActive" Visible="false">
                                            <p>
                                                Vui lòng nhập lý do hủy đơn hàng
                                                <asp:TextBox runat="server" TextMode="MultiLine" ID="txtBuyerCancel" CssClass="txt_mes"
                                                    MaxLength="300" Rows="3" Width="99%"></asp:TextBox></p>
                                            <asp:Button runat="server" CssClass="button_V" ID="Button2" Text="Hủy" OnClick="btnBuyerCancel_Click" />
                                        </asp:Panel>
                                        <asp:Panel CssClass="pnSellerActive" runat="server" ID="pnBuyerConfirm" Visible="false">
                                            <p>
                                                <table>
                                                    <tr valign="top">
                                                        <td>
                                                            <input runat="server" id="rdBECF_1" type="radio" name="pnBECF" checked="true" />
                                                            <label>
                                                                Xác nhận hoàn thành</label>
                                                        </td>
                                                        <td>
                                                            <input id="rdBECF_0" runat="server" type="radio" name="pnBECF" />
                                                            <label>
                                                                Từ chối nhận đơn hàng
                                                                <br />
                                                                Người bán sẽ làm lại những công việc theo yêu cầu
                                                            </label>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </p>
                                            <p class="action-message" style="display: none">
                                                Vui lòng nhập lý do không nhận đơn hàng của bạn
                                                <asp:TextBox runat="server" TextMode="MultiLine" ID="txtBuyerConfirmCancel" CssClass="txt_mes"
                                                    MaxLength="300" Rows="3" Width="99%"></asp:TextBox></p>
                                            <asp:Button runat="server" CssClass="button_V" ID="Button4" Text="Submit" OnClick="btnBuyerConfirm_Click" />
                                        </asp:Panel>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </asp:Panel>
                    <div style="clear: both">
                    </div>
                    <asp:Panel runat="server" ID="pnRate" Visible="false">
                        <div class="order-complete-rate">
                            <span>đánh giá công việc này</span><img src="img/rate_up.png" /><asp:RadioButton
                                runat="server" ID="rdRateUp" GroupName="rdRate" Checked="true" />
                            <img src="img/rate_down.png" />
                            <asp:RadioButton ID="rdRateDown" GroupName="rdRate" runat="server" /></div>
                        <%--  <asp:TextBox Width="100%" TextMode="MultiLine" Rows="5" runat="server" ID="txtRateComment"></asp:TextBox>--%>
                        <textarea runat="server" rows="5" id="txtRateComment" style="width: 95%; border: 1px solid #BAC1D2"></textarea>
                        <asp:Button runat="server" CssClass="button_V" ID="btnRate" Text="Submit" OnClick="btnRate_Click" />
                    </asp:Panel>
                    <asp:Panel runat="server" ID="pnRemoveRate" Visible="false">
                        <span style="color: #aaaaaa; text-transform: uppercase">Bạn đã đánh giá công việc này
                            rồi, nếu muốn đánh giá lại vui lòng click vào</span>
                        <asp:LinkButton runat="server" ID="lbtRemoveRate" OnClick="lbtRemoveRate_Click"> ĐÂY</asp:LinkButton>
                    </asp:Panel>
                </div>
            </div>
            <%-- </ContentTemplate>
            </asp:UpdatePanel>--%>
            <!-- END Nhap noi dung mess -->
            <div class="clear">
            </div>
            <!-- ket  thuc noi dung -->
        </div>
        <!-- vitri cua sidebar_right -->
    
    <script type="text/javascript">
        $(function () {
            $(".txt_mes").val() == ""
            $('.upfile').hide();
            $('.txt_mes').css("border", "1px solid #0871b4");
            $('.attach').click(function () {
                $('.upfile').toggle();
                return false;
            });
            $('.txt_mes').focus(function () {
                $('.txt_mes').css("border", "1px solid #0b99f3");
            });
        });
        function check() {
            if ($(".txt_mes").val() == "") {
                alert("Bạn không được để trống !");
                $(".txt_mes").focus();
                return false;
            }
        }
        $("#showMessage").click(function () {
            $(".messageHide").show(0);
            $(".pnSellerActive").hide(0);
        })
        $("#<%=showAction.ClientID %>").click(function () {
            $(".messageHide").hide(0);
            //$(".pnSellerActive").show(0);         
            $(".pnSellerActive").toggle();
        })



        $("#imgTest").error(function () { alert("e"); })

        $(".wrap_mess img").each(function (index) {
            $(this).error(function () {
                $(this).attr('src', 'avatar/noavatar.jpg');
            });
        });
        //an hien textbox panel seller khi nhan dc don hang
        $("#<%=rdSLAT_0.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").show();
            else
                $(".action-message").hide();
        });
        $("#<%=rdSLAT_1.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").hide();

        });
        $("#<%=rdSLAT_2.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").show();
            else
                $(".action-message").hide();

        });
        //end
        //an hien nhap textbox panel seller khi da xac nhan don hang
        $("#<%=rdSLCF_1.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").hide();

        });
        $("#<%=rdSLCF_0.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").show();
            else
                $(".action-message").hide();

        });
        //end
        //an hien nhap textbox panel seller khi buyer ko nhan don hang va lam lai
        $("#<%=rdSLRJ_1.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").hide();

        });
        $("#<%=rdSLRJ_0.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").show();
            else
                $(".action-message").hide();

        });
        $("#<%=rdSLRJ_2.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").show();
            else
                $(".action-message").hide();

        });
        //end
        //an hien nhap textbox panel buyer 
        $("#<%=rdBECF_1.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").hide();

        });
        $("#<%=rdBECF_0.ClientID %>").click(function () {
            var b = $(this).is(':checked');
            if (b)
                $(".action-message").show();
            else
                $(".action-message").hide();

        });
        //end

        $(document).ready(function () {
            $(".pnSellerActive").hide(0);
            $("#lblBuyerConfirmCancel").click(function () {
                $.ajax({
                    type: "POST",
                    url: "orders.aspx/BuyerConfirmCancelOrder",
                    data: '{orderId: "' + $("#<%= hdID.ClientID%>").val() + '" }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                    success: OnSuccess,
                    failure: function (response) {
                        alert("Có lỗi xảy ra, vui lòng thực hiện lai");
                    }
                });

            });
            $("#lblSellerConfirmCancel").click(function () {
                $.ajax({
                    type: "POST",
                    url: "orders.aspx/SellerConfirmCancelOrder",
                    data: '{orderId: "' + $("#<%= hdID.ClientID%>").val() + '" }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: OnSuccess,
                    failure: function (response) {
                        alert("Có lỗi xảy ra, vui lòng thực hiện lai");
                    }
                });
            });
        });
        function OnSuccess(response) {
            if (response.d == 0) {
                alert("Có lỗi xảy ra, vui lòng thực hiện lai");
            }
            else if (response.d == 1)
                window.location.href = window.location;
            else if (response.d == 2)
                alert("Đơn hàng đã hủy, không thể hủy tiếp");

        };
    </script>
    </div>
</asp:Content>
